package com.qiang.test05;

import java.lang.reflect.Constructor;

public class Demo01 {
    public static void main(String[] args) throws NoSuchMethodException {

        //获取class对象
        Class sc = Student.class;

        //获取所有公共构造方法
        Constructor[] constructor = sc.getConstructors();
        for (Constructor constructor1 : constructor) {
            System.out.println(constructor1);
        }


        System.out.println("================");

        //获取所有构造方法
        Constructor[] scc = sc.getDeclaredConstructors();
        for (Constructor constructor1 : scc) {
            System.out.println(constructor1);
        }

        System.out.println("================");

        //获取单个的公共构造方法

        Constructor dc = sc.getDeclaredConstructor();
        System.out.println(dc);

        System.out.println("================");

        //获取单个公共构造方法
        Constructor dc2 = sc.getDeclaredConstructor(String.class, int.class);
        System.out.println(dc2);

        System.out.println("================");

        //获取私有的构造方法
        Constructor dc3 = sc.getDeclaredConstructor(String.class);
        System.out.println(dc3);
    }
}
